Learning Flex Basics (Part 2): Creating a Simple Calculator with Macromedia Flex
Table of Contents
- Introduction
- Building the Calculator
- Create the Application Object
- Add a Panel for the Calculator
- Add the Calculator Display
- Add a Grid to Lay Out the Buttons
- Add the Calculator Buttons
- Create the CalculatorController Class
- Add Properties to the Controller Class
- Add Controller Methods
- Instantiate the CalculatorController Class
- Complete Code Listing for calculator.mxml
- Complete Code Listing for CalculatorController.as
- Where to Go From Here
Where to Go from Here
Although the calculator you have built here is simple, it works, and if you actually need to build a calculator of some kind, you could easily extend this one to include additional functionality. ActionScript includes a static Math class whose methods would do a lot of the work for you. More importantly, though, you should feel comfortable now with basic elements of MXML and ActionScript, and ready to start tackling more sophisticated applications.
Continue on to the following tutorials to learn more:
- Learning Flex Basics (Part 3): Working with Containers
- Learning Flex Basics (Part 4): Working with Data Models
If you prefer, you can download the entire set of tutorials, Learning Flex Series (Parts 1-4). If you like what you see and want to get more experience with Flex, Macromedia Customer Training offers Fast Track to Macromedia Flex, a two-day onsite training course to jump-start Flex development in your organization. You should also look at the informative set of sample applications in included with Flex; these illustrate the use of many Flex features.